#ifndef __FSM_TIMER_H__
#define __FSM_TIMER_H__

#include "stdint.h"

typedef void (*timer_func)(void);

struct timer_list_t {
    struct timer_list_t *prev;
    struct timer_list_t *next;
    
    uint16_t    nTicks;
    uint16_t    interval;
    
    timer_func  func;   // 调用函数
};

typedef enum {
    fsm_timer_one_flg = 1,
    fsm_timer_period_flg,
} fsm_timer_ctr;

void fsm_timer_init(struct timer_list_t *n, timer_func func, uint16_t nTicks, fsm_timer_ctr flg);
void fsm_timer_set(struct timer_list_t *n, uint16_t nTicks, fsm_timer_ctr flg);
int  fsm_timer_start(struct timer_list_t *n);
int  fsm_timer_stop(struct timer_list_t *n);
int  fsm_timer_isActive(struct timer_list_t *n);
void fsm_timer_handler(void);
void fsm_system_timer_init(void);

#define system_timer_mode       fsm_timer_period_flg
#define system_nTicks_cnt       500

extern void fsm_system_timerfunc(void);

#endif
